package com.thti.mecool.client.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.thti.mecool.client.activity.R;
import com.thti.mecool.client.model.po.Task;

public class MyplanAdapter extends BaseAdapter {
	List<Task> list;
	Context context;
	
	public MyplanAdapter(List<Task> list, Context context) {
		super();
		this.list = list;
		this.context = context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		LinearLayout layout=new LinearLayout(context);
		layout.setBackgroundResource(R.drawable.mecool_listview_selector);
		layout.setOrientation(1);
		TextView projectName=new TextView(context);
		projectName.setText(list.get(position).getProjectName());
		TextView showTime=new TextView(context);
		showTime.setText(list.get(position).getStartTime()+"-"+list.get(position).getEndTime());
		TextView taskName=new TextView(context);
		taskName.setText(list.get(position).getTaskName());
		TextView storeName=new TextView(context);
		storeName.setText(list.get(position).getStoreName());
		layout.addView(projectName);
		layout.addView(showTime);
		layout.addView(taskName);
		layout.addView(storeName);
		return layout;
	}

}
